package com.lancoo.klgcourseware.entity;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by pengmi on 2018/11/13.
 * Description:词汇类型训练模型
 */

public class WordPracticeModel implements Parcelable {

    //例句（其中 &*为挖空数据）
    private String Sentence;
    //例句翻译
    private String Translate;
    //例句音频路径
    private String Senvoice;

    private String VoiceTime;



    //挖空数据列表
    private List<HideWordModel> HideWordList;


    public String getSentence() {
        return Sentence;
    }

    public void setSentence(String sentence) {
        Sentence = sentence;
    }

    public String getTranslate() {
        return Translate;
    }

    public void setTranslate(String translate) {
        Translate = translate;
    }

    public String getSenvoice() {
        if(!TextUtils.isEmpty(Senvoice)){
            Senvoice= Senvoice.replace("//////","/").replace("/////","/").replace("////","/").replace("///","/").replace("//","/");
            if(TextUtils.equals("/",Senvoice.substring(0,1))){
                Senvoice=Senvoice.substring(1);
            }
        }
        return Senvoice;
    }

    public void setSenvoice(String senvoice) {
        Senvoice = senvoice;
    }

    public List<HideWordModel> getHideWordList() {
        return HideWordList;
    }

    public void setHideWordList(List<HideWordModel> hideWordList) {
        HideWordList = hideWordList;
    }

    public String getVoiceTime() {
        return VoiceTime;
    }

    public void setVoiceTime(String VoiceTime) {
        this.VoiceTime = VoiceTime;
    }

    public int getIntVoiceTime(){
        if(TextUtils.isEmpty(VoiceTime)){
            return 2500;
        }else{
            try{
                int intTime=Integer.parseInt(VoiceTime);
                return intTime;
            }catch (Exception e){
                return 2500;
            }
        }
    }

    public WordPracticeModel() {
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeString(Sentence);
        parcel.writeString(Translate);
        parcel.writeString(Senvoice);
        parcel.writeString(VoiceTime);
        parcel.writeTypedList(HideWordList);
    }

    public WordPracticeModel(Parcel in){
        Sentence=in.readString();
        Translate=in.readString();
        Senvoice=in.readString();
        VoiceTime=in.readString();
        if(HideWordList==null){
            HideWordList=new ArrayList<>();
        }
        in.readTypedList(HideWordList,HideWordModel.CREATOR);
    }

    public static final Creator<WordPracticeModel> CREATOR= new Creator<WordPracticeModel>() {
        public WordPracticeModel createFromParcel(Parcel in) {
            return new WordPracticeModel(in);
        }

        public WordPracticeModel[] newArray(int size) {
            return new WordPracticeModel[size];
        }
    };
}
